/** @type {import('next').NextConfig} */

// 获取部署模式，默认为 'dist'
const deployMode = process.env.DEPLOY_MODE || "dist";

const baseConfig = {
  output: "export",
  // 启用 HTTPS 开发服务器
  ...(process.env.NODE_ENV === "development" && {
    experimental: {
      https: true,
    },
  }),
};

const distConfig = {
  ...baseConfig,
  distDir: "dist",
};

const yjsConfig = {
  ...baseConfig,
  distDir: "web",
  assetPrefix: process.env.NODE_ENV === "production" ? "./" : "",
  basePath: process.env.NODE_ENV === "production" ? "" : "",
  images: {
    unoptimized: true,
  },
  trailingSlash: true,
};

let nextConfig;

switch (deployMode) {
  case "web":
    nextConfig = yjsConfig;

    break;
  case "dist":
  default:
    nextConfig = distConfig;

    break;
}
console.log("nextConfig", nextConfig);

export default nextConfig;
